1) Field of the Invention
The present invention relates to a method for facilitating optimization in a compiler. The present invention also relates to a compiler in which provision is made for facilitating the optimization. The present invention further relates to an apparatus for facilitating optimization processing in a compiler.
2) Description of the Related Art
In the usual compilers, syntax analysis and the like of a source code are performed at the front end, and an object code is generated at the back end. In addition, the object code is optimized for enhancing efficiency of execution of the object code. For example, when the program includes an array description, the array may be recognized as a loop. Since loop operations occupy a considerable time in the execution of the object code, array portions of the object code is required to be optimized.
In some programming languages such as Fortran 90 and Fortran 95, values of or relationships between variables may be determined based on standardized rules or restrictions specified for the programming languages, although such rules or restrictions are specified in different manners depending on the programming languages. For example, in Fortran 90 or Fortran 95, scalar representations of arrays as illustrated in FIG. 8(A) can be rewritten in vector representations as illustrated in FIG. 8(B), while in C and FORTRAN 77, access to arrays can be described in only element by element. According to the rules and restrictions of Fortran 90 or Fortran 95, the value of the variable L in the description in the fourth line of the text illustrated in FIG. 8(B) can be determined to be 100.
Loop fusion is one of the well-known optimization techniques, and is a technique of decreasing the number of loops for reducing overheads which are required for loop control. That is, a plurality of loops satisfying a predetermined condition are combined into a single loop. For loop fusion, some sophisticated techniques are known for analyzing relationships between arrays.
Further, Japanese Unexamined Patent Publication, No. 9-62514 discloses a method for facilitating loop fusion processing which is performed for optimizing the program code. In the method, a technique for analyzing relationships between arrays is used. To be more specific, JPP 9-62514 discloses facilitation of loop fusion processing by using a function of analyzing subscripts of the arrays in a program code, which is described in a programming language allowing vector representations of arrays, such as Fortran 90 and Fortran 95. For example, FIG. 9 exhibits an example of a result of loop fusion, which is obtained by the subscript analysis of arrays in a program code. The subscript analysis is performed on the three assignment statements expressed by arrays, which are indicated in the upper rectangle in FIG. 9. The result of the subscript analysis is utilized for producing an optimum (fused) loop, as indicated in the lower rectangle in FIG. 9. According to the rules and restrictions specified for the above programming language such as Fortran 90 and Fortran 95, the sizes of the arrays on the right-hand side and the left-hand side of each assignment statement are identical. Therefore, the result of subscript analysis performed on the arrays in the three assignment statements in the upper rectangle in FIG. 9 shows that L=5=M−1=N−2. This result is used for facilitation of the loop fusion processing and production of a fused loop having an optimum form, as illustrated in FIG. 9. For example, the number of iterations in the fused DO loop is determined as L=5 by the above subscript analysis, in advance of the loop fusion processing.
As described above, conventionally, the result of subscript analysis of arrays is utilized for facilitating the loop fusion processing. However, the result of subscript analysis of arrays is not utilized in optimization processing other than the loop fusion processing.